package com.habdqn.ssm.etm.service.impl;

import com.habdqn.ssm.etm.entity.EnterpriseTalent;
import com.habdqn.ssm.etm.dao.EnterpriseTalentDao;
import com.habdqn.ssm.etm.service.EnterpriseTalentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (EnterpriseTalent)表服务实现类
 *
 * @author xing.jiejian
 * @since 2019-11-16 10:51:39
 */
@Service("enterpriseTalentService")
public class EnterpriseTalentServiceImpl implements EnterpriseTalentService {
    @Resource
    private EnterpriseTalentDao enterpriseTalentDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public EnterpriseTalent queryById(Integer id) {
        return this.enterpriseTalentDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param pageNo 页码
     * @param pageSize 查询条数
     * @param departmentId 部门编号
     * @return 对象列表
     */
    @Override
    public List<EnterpriseTalent> queryAllByLimit(int pageNo, int pageSize,int departmentId) {
        EnterpriseTalent  et = null;
        if(departmentId>0){
            et = new EnterpriseTalent();
            et.setDepartmentId(departmentId);
        }
        return this.enterpriseTalentDao.queryLimitByEntity((pageNo-1)*pageSize, pageSize,et);
    }

    @Override
    public int queryCountByDepartmentId(int departmentId) {
        EnterpriseTalent  et = null;
        if(departmentId>0){
            et = new EnterpriseTalent();
            et.setDepartmentId(departmentId);
        }
        return enterpriseTalentDao.queryCountByEntity(et);
    }

    /**
     * 新增数据
     *
     * @param enterpriseTalent 实例对象
     * @return 实例对象
     */
    @Override
    public EnterpriseTalent insert(EnterpriseTalent enterpriseTalent) {
        this.enterpriseTalentDao.insert(enterpriseTalent);
        return enterpriseTalent;
    }

    /**
     * 修改数据
     *
     * @param enterpriseTalent 实例对象
     * @return 实例对象
     */
    @Override
    public EnterpriseTalent update(EnterpriseTalent enterpriseTalent) {
        this.enterpriseTalentDao.update(enterpriseTalent);
        return this.queryById(enterpriseTalent.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.enterpriseTalentDao.deleteById(id) > 0;
    }
}